<!doctype html>
<html>
	<head>
		<title>Rendering snow with shaders tutorial / 7</title>
		<link rel="stylesheet" type="text/css" href="style.css" />
		<script type="text/javascript" src="libs/three-r54.min.js"></script>
		<script type="text/javascript" src="libs/dat.gui.min.js"></script>
		<script type="text/javascript" src="step07.js"></script>
	</head>
	<body>
		<script type="x-shader/x-vertex" id="step07_vs">
			uniform float radiusX;
			uniform float radiusZ;
			uniform float size;
			uniform float scale;
			uniform float height;
			uniform float elapsedTime;

			void main() {
				vec3 pos = position;
				pos.x += cos((elapsedTime + position.z) * 0.25) * radiusX;
				pos.y = mod(pos.y - elapsedTime, height);
				pos.z += sin((elapsedTime + position.x) * 0.25) * radiusZ;

				vec4 mvPosition = modelViewMatrix * vec4( pos, 1.0 );

				gl_PointSize = size * ( scale / length( mvPosition.xyz ) );

				gl_Position = projectionMatrix * mvPosition;
			}
		</script>

		<script type="x-shader/x-fragment" id="step04_fs">
			uniform vec3 color;

			void main() {
				gl_FragColor = vec4( color, 1.0 );
			}
		</script>
	</body>
</html>


